<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<script type="text/javascript">
		<!--
			var ligerTable = null;
			$(function(){
				ligerTable = $('#table').ligerGrid({
					width:'98%',
					enabledSort:false,
					pageSizeOptions:[5,10,20,50,100,200],
					height:'auto',
					alternatingRow:true,
					url:'${base}/${route}/getList',
					delayLoad:false,
					columns:[
						{display:'订单号',name:'orderNo',id:'orderNo',align:'center',minWidth:200},
						{display:'发布者',name:'publisherName',id:'publisherName',align:'center',minWidth:150},
						{display:'货物名称',name:'goodsName',id:'goodsName',align:'center',minWidth:150},
						{display:'联系方式',name:'contact',id:'contact',align:'center',minWidth:80},
						{
							display:'状态',
							name:'status',
							id:'status',
							align:'center',
							minWidth:150,
							render:function(row){
						 		var status = row.status;
						 		if(status == 1){
						 			return '发布';
						 		}
						 		else if(status == 2){
						 			return '完成';
						 		}
						 		return '-';
							}
						},
						{
							display:'显示平台',
							name:'platform',
							id:'platform',
							align:'center',
							minWidth:150,
							render:function(row){
								var platform = row.platform;
						 		var pfs = platform.split(',');
						 		var len = pfs != null ? pfs.length : 0;
						 		var html = '';
						 		for(var i = 0; i < len; i++){
						 			var p = pfs[i];
						 			<#if platforms?exists>
						 				<#list platforms as platform>
						 					if( p == '${platform.platformValue}'){
						 						html += '${platform.platformName}  ';
						 					}
						 				</#list>
						 			</#if>
						 		}
						 		return html;
							}
						},
						{
							display:'发布时间',
							name:'createTime',
							id:'createTime',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.createTime > 0){
						 			return formatDate(row.createTime * 1000);
						 		}
						 		return '-';
							}
						},
						{display:'认领人',name:'claimant',id:'claimant',align:'center',minWidth:80},
						{
							display:'完成时间',
							name:'completeTime',
							id:'completeTime',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.completeTime > 0){
						 			return formatDate(row.completeTime * 1000);
						 		}
						 		return '-';
							}
						}
					],
					onDblClickRow: function (data, rowindex, rowobj){
						layer.open({
							title:'${module}',
							type:2,
							maxmin:false,
							area: ['100%', '100%'],
							content:'${base}/${route}/view/'+data.orderNo
						});
					}
				});
				
				function reload(){
					if(ligerTable){
						var searchKey = $('#txtSearchKey').val();
						ligerTable.setParm('searchKey',searchKey);
						ligerTable.reload();
					}
				}
				$('#btnSearch').click(function(){
					reload();
				})
				
				$('#btnComplete').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || !row.orderNo || row.orderNo.length < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var status = row.status;
			    		if(status != 1){
			    			var tip = '订单状态错误';
			    			if(status == 2){
			    				tip = '订单已完成';
			    			}
			    			layer.msg(tip)
			    			return;
			    		}
			    		var orderNo = row.orderNo;
			        	var url='${base}/${route}/complete/'+orderNo;
			            changePage(url);
			    	}
				});
			});
		//-->
		</script>
	</head>
	<body class="$configs["skinName"]">
		<#include "common/breadcrumb.ftl">
		<div class="widget-box">
			<div class="widget-header widget-header-flat">
				<h5 class="lighter">
					<i class="fa fa-search"></i>
					${module}查询
				</h5>
			</div>
			<div class="widget-body">
				<div class="widget-main">
					<div class="row">
						<div class="col-xs-5 col-sm-5">
							<div class="input-group">
								<span class="input-group-addon">关键字</span>
								<input id="txtSearchKey" type="text" class="form-control search-query" placeholder="请输入关键字搜索" />
								<span class="input-group-btn">
									<button id="btnSearch" type="button" class="btn btn-primary btn-sm">
										查询
										<i class="fa fa-search bigger-110"></i>
									</button>
								</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="widget-box">
			<div class="widget-header">
				<h5 class="lighter">
					<i class="icon-table"></i>
					${module}列表
				</h5>
				<!--非查询者有该操作-->
				<!--
				<#if user?exists && viewerRole?exists && user.roleId != viewerRole>
				<div class="widget-toolbar">
					<button id="btnComplete" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-repeat"></i>完成
					</button>
				</div>
				</#if>
				-->
			</div>
			<div class="widget-body">
				<div id="table"><div>
			</div>
		</div>
	</body>
</html>